//
//  MyCompensationViewController.m
//  SsehMaster
//
//  Created by 杨阳 on 2018/8/4.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#import "MyCompensationViewController.h"
#import "MyCompensationTableViewCell.h"

@interface MyCompensationViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView * tableView;

@end

NSString * const MyCompensationTableViewCellID = @"MyCompensationTableViewCellID";

@implementation MyCompensationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self layoutUI];
}

-(void)layoutUI{
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, -STATUS_BAR_HEIGHT, VIEW_WIDTH, VIEW_HEIGHT+STATUS_BAR_HEIGHT) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.showsHorizontalScrollIndicator = NO;
    self.tableView.backgroundColor = [UIColor backGroudColorForView];
    [self.tableView registerNib:[UINib nibWithNibName:@"MyCompensationTableViewCell" bundle:nil] forCellReuseIdentifier:MyCompensationTableViewCellID];
    [self.view addSubview:self.tableView];
    
    UIView * headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, VIEW_WIDTH, 115+41+NAVIGATION_BAR_HEIGHT)];
    headerView.backgroundColor = [UIColor appColor];
    self.tableView.tableHeaderView = headerView;
    
    
    UIView * backBgView = [UIView new];
    [headerView addSubview:backBgView];
    [backBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top).offset(STATUS_BAR_HEIGHT);
        make.left.equalTo(headerView.mas_left).offset(10);
        make.size.mas_equalTo(CGSizeMake(44, 44));
    }];
    
    UIImageView * backImageView = [[UIImageView alloc]init];
    backImageView.image = [UIImage imageNamed:@"backShap"];
    backImageView.userInteractionEnabled = YES;
    [backBgView addSubview:backImageView];
    [backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.centerX.equalTo(backBgView);
        make.size.mas_equalTo(CGSizeMake(12, 21));
    }];
    
    UITapGestureRecognizer * backTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(backVC)];
    [backBgView addGestureRecognizer:backTap];
    
    UILabel * vcTitleLabel = [UILabel new];
    vcTitleLabel.textColor = [UIColor whiteColor];
    vcTitleLabel.text = @"我的薪资";
    vcTitleLabel.textAlignment = NSTextAlignmentCenter;
    vcTitleLabel.font = [UIFont systemFontOfSize:16];
    [headerView addSubview:vcTitleLabel];
    [vcTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_top).offset(STATUS_BAR_HEIGHT);
        make.centerX.equalTo(headerView.mas_centerX);
        make.height.mas_equalTo(44);
    }];
    
    UIView * bgView = [UIView new];
    [headerView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(NAVIGATION_BAR_HEIGHT, 0, 41, 0));
    }];
    

    UILabel * compensationLabel = [UILabel new];
    compensationLabel.text = @"1150.00";
    compensationLabel.font = [UIFont systemFontOfSize:14];
    compensationLabel.textColor = [UIColor whiteColor];
    compensationLabel.textAlignment = NSTextAlignmentCenter;
    [bgView addSubview:compensationLabel];
    

    UILabel * titleLabel = [UILabel new];
    titleLabel.text = @"我的薪资";
    titleLabel.font = [UIFont systemFontOfSize:14];
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [bgView addSubview:titleLabel];
    
    [compensationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(bgView);
        make.bottom.equalTo(titleLabel.mas_top);
    }];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(bgView);
        make.height.equalTo(compensationLabel);
    }];
    
    UIView * bottomBgView = [UIView new];
    bottomBgView.backgroundColor = [UIColor whiteColor];
    [headerView addSubview:bottomBgView];
    [bottomBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(headerView);
        make.top.equalTo(bgView.mas_bottom);
    }];
    
    UIImageView * leftImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logoT_select"]];
    [bottomBgView addSubview:leftImageView];
    [leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomBgView.mas_left).offset(16);
        make.centerY.equalTo(bottomBgView);
        make.size.mas_equalTo(CGSizeMake(13, 15));
    }];
    
    UILabel * detailTitleLabel = [UILabel new];
    detailTitleLabel.text = @"薪资明细";
    detailTitleLabel.font = [UIFont systemFontOfSize:14];
    detailTitleLabel.textColor = [UIColor textDarkGrayColor];
    detailTitleLabel.textAlignment = NSTextAlignmentCenter;
    [bottomBgView addSubview:detailTitleLabel];
    
    [detailTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(leftImageView.mas_right).offset(10);
        make.centerY.equalTo(bottomBgView);
    }];
    UIView * bottomLineView = [UIView new];
    bottomLineView.backgroundColor = [UIColor backGroudColorForView];
    [bottomBgView addSubview:bottomLineView];
    [bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bottomBgView.mas_left).offset(10);
        make.right.equalTo(bottomBgView.mas_right).offset(-10);
        make.bottom.equalTo(bottomBgView);
        make.height.mas_equalTo(1);
    }];
}

-(void)backVC{
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 53;
}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    MyCompensationTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:MyCompensationTableViewCellID];
    cell.selectionStyle                = UITableViewCellSelectionStyleNone;
    
    return cell;
    
}

-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = YES;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
